package cn.shiwei.hr.task;

import cn.shiwei.hr.service.IKillCourseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.ParseException;
import java.util.HashMap;

@Slf4j
@Component
public class KillCourseTask {

    @Autowired
    private IKillCourseService killCourseService;

    @Scheduled(cron = "0/10 * * * * *")
    @Async // 标记为异步方法, spring默认为同步方法, 标记 为异步后独立运行
    public void killCoursePublish() throws ParseException {
        log.info("定时发布秒杀课程任务开启");
        killCourseService.publishASpikeCourse();

    }

}
